<%@page import="db.dao.*"%>
<%@ page language="java" contentType="text/html;" import="java.util.*" pageEncoding="UTF-8" %>
<%
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>教务系统管理界面</title>
		<link href="css/jquery-accordion-menu.css" rel="stylesheet" type="text/css" />
		<link href="css/font-awesome.css" rel="stylesheet" type="text/css" />
		<link href="css/stm.css" rel="stylesheet" type="text/css"/>
		<link href='http://cdn.webfont.youziku.com/webfonts/nomal/104133/46121/59478b3cf629d81a84e7e13e.css' rel='stylesheet' type='text/css' />
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700">
		<style type="text/css">
			* {
				box-sizing: border-box;
				-moz-box-sizing: border-box;
				-webkit-box-sizing: border-box;
			}
			
			body {
				background: #3b424d;
			}
			
			.content {
				width: 260px;
				margin: 20px auto;
			}
			
			.filterinput {
				background-color: rgba(249, 244, 244, 0);
				border-radius: 15px;
				width: 90%;
				height: 30px;
				border: thin solid #FFF;
				text-indent: 0.5em;
				font-weight: bold;
				color: #FFF;
			}
			
			#demo-list a {
				overflow: hidden;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
				white-space: nowrap;
				width: 100%;
			}
		</style>
		<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
		<script src="js/jquery-accordion-menu.js" type="text/javascript"></script>
		<script type="text/javascript">
			$(function() {
				//顶部导航切换
				$("#demo-list li").click(function() {
					$("#demo-list li.active").removeClass("active")
					$(this).addClass("active");
				})
			})
		</script>
	</head>
	<body>
		<div class="content" style="float: left">
			<div id="jquery-accordion-menu" class="jquery-accordion-menu #313131" >
				<div class="jquery-accordion-menu-header" id="form"></div>
				<ul id="demo-list">
					<%
					String goURL = "";
					if (session.getAttribute("usertype").equals("学生")) {
						goURL = "student.jsp";
					}else if (session.getAttribute("usertype").equals("教师")) {
						goURL = "teacher.jsp";
					}else if (session.getAttribute("usertype").equals("管理")) {
						goURL = "manage.jsp";
					}
					%>
					<li class="active"><a href="<%=goURL %>"><i class="fa fa-home"></i>返回 </a></li>
				</ul>
				<div class="jquery-accordion-menu-footer">
					欢迎使用重庆理工大学教务系统
				</div>
			</div>
		</div>
		<div class="InfoDiv">
			<div title="查询结果" align="center">
				<table style="width:80%;color: whitesmoke;" align="center">
					<%
					String str = (String) session.getAttribute("search");
					if(str.equals("classes")) {
					 %>
					 <tr>
					 	<td>班级编号</td>
					 	<td>班级名称</td>
					 	<td>班级人数</td>
					 	<td>所属专业</td>
					 	<td>所属学院</td>
					 </tr>
					 <%
					 Classes classes = new Classes();
					 Set<Classes> list = (Set<Classes>)session.getAttribute("classes");
					 Iterator<Classes> iterator = list.iterator();
					 while(iterator.hasNext()) {
					 	classes = iterator.next();
					  %>
					  <tr>
					  	<td><%=classes.getClassid() %></td>
					  	<td><%=classes.getClassname() %></td>
					  	<td><%=classes.getStunumbers() %></td>
					  	<td><%=classes.getMajor().getMajorname() %></td>
					  	<td><%=classes.getDept().getDeptname() %></td>
					  </tr>
					 <%}}else if(str.equals("courclasses")){
					 %>
					 	<tr>
						 	<td>教师名称</td>
						 	<td>课程名称</td>
						 	<td>班级容量</td>
						 	<td>地点</td>
						</tr>
					 <%
					 CourClass courclasses = new CourClass();
					 List<CourClass> list = (List<CourClass>)session.getAttribute("courclasses");
					 Iterator<CourClass> iterator = list.iterator();
					 while(iterator.hasNext()) {
					 	courclasses = iterator.next();
					 %>
					 <tr>
					  	<td><%=courclasses.getTeacher().getTeaname() %></td>
					  	<td><%=courclasses.getCourse().getCoursename() %></td>
					  	<td><%=courclasses.getStunumbers() %></td>
					  	<td><%=courclasses.getPlace() %></td>
					  </tr>
					 <%}}else if(str.equals("courses")){
					 %>
					 <tr>
						 	<td>课程编号</td>
						 	<td>课程名称</td>
						 	<td>学分</td>
						 	<td>考核方式</td>
						 	<td>课程性质</td>
						</tr>
					<%
					Course courses = new Course();
					Set<Course> list = (Set<Course>)session.getAttribute("courses");
					Iterator<Course> iterator = list.iterator();
					while(iterator.hasNext()) {
					 	courses = iterator.next();
					 %>
					 <tr>
					 	<td><%=courses.getCourseid() %></td>
					 	<td><%=courses.getCoursename() %></td>
					 	<td><%=courses.getCredit() %></td>
					 	<td><%=courses.getExamination() %></td>
					 	<td><%=courses.getNature() %></td>
					 </tr>
					  <%}}else if(str.equals("depts")){
					 %>
					 <tr>
						 <td>学院编号</td>
						 <td>学院名称</td>
						 <td>下属专业编号</td>
						 <td>下属专业名称</td>
					</tr>
					<%
					 Dept depts = new Dept();
					 Set<Dept> list = (Set<Dept>)session.getAttribute("depts");
					 Iterator<Dept> iterator = list.iterator();
					 Major m = new Major();
					 while(iterator.hasNext()) {
					 	depts = iterator.next();
					 	Iterator<Major> i = depts.getMajors().iterator();
					 	while(i.hasNext()){
					 		m = i.next();
					 %>
					 <tr>
					  	<td><%=depts.getDeptid() %></td>
					  	<td><%=depts.getDeptname() %></td>
					  	<td><%=m.getMajorid() %></td>
					  	<td><%=m.getMajorname() %></td>
					 </tr> 
					  <%}}}else if(str.equals("majors")){
					  %>
					  <tr>
						 <td>专业编号</td>
						 <td>专业名称</td>
						 <td>所属学院</td>
					</tr>
					<%
					 Major majors = new Major();
					 Set<Major> list = (Set<Major>)session.getAttribute("majors");
					 Iterator<Major> iterator = list.iterator();
					 while(iterator.hasNext()) {
					 	majors = iterator.next();
					 %>
					 <tr>
					  	<td><%=majors.getMajorid() %></td>
					  	<td><%=majors.getMajorname() %></td>
					  	<td><%=majors.getDept().getDeptname() %></td>
					 </tr> 
					  <%}}else if(str.equals("stucourses")){
					  %>
					  <tr>
						 <td>学号</td>
						 <td>姓名</td>
						 <td>课程编号</td>
						 <td>课程名称</td>
						 <td>任课教师</td>
						 <td>成绩</td>
					  </tr>
					  <%
					   StuCourse stucourses = new StuCourse();
					   List<StuCourse> list = (List<StuCourse>)session.getAttribute("stucourses");
					   Iterator<StuCourse> iterator = list.iterator();
					   while(iterator.hasNext()) {
					   	stucourses = iterator.next();
				   	  %>
					   <tr>
					    	<td><%=stucourses.getStudent().getStuid() %></td>
					    	<td><%=stucourses.getStudent().getStuname() %></td>
					    	<td><%=stucourses.getId().getCourseid() %></td>
					    	<td><%=stucourses.getTeaCourse().getCoursename() %></td>
					    	<td><%=stucourses.getTeaCourse().getTeaname() %></td>
					    	<%
					    		Short score = stucourses.getScore();
					    		if(score!=null){
					    	%>
					    	<td><%=score %></td>
					    	<%}else{ %>
					    	<td><%="" %></td>
					   </tr> 
					    <%}}}else if(str.equals("students")){
					  	%>
						  <tr>
							 <td>学号</td>
							 <td>姓名</td>
							 <td>性别</td>
							 <td>身份证号</td>	
							 <td>班级</td>
							 <td>专业</td>
							 <td>院系</td>
							 <td>学制</td>
						</tr>
						<%
						 Student students = new Student();
						 Set<Student> list = (Set<Student>)session.getAttribute("students");
						 Iterator<Student> iterator = list.iterator();
						 while(iterator.hasNext()) {
						 	students = iterator.next();
						 %>
						 <tr>
						  	<td><%=students.getStuid() %></td>
						  	<td><%=students.getStuname() %></td>
						  	<td><%=students.getStusex() %></td>
						  	<td><%=students.getStuidentify() %></td>
						  	<td><%=students.getClasses().getClassid() %></td>
						  	<td><%=students.getClasses().getMajor().getMajorname() %></td>
						  	<td><%=students.getClasses().getDept().getDeptname() %></td>
						  	<td><%=students.getStuedulength() %></td>
						 </tr> 
					<%}}else if(str.equals("teachers")){
					%>
					<tr>
						 <td>教师编号</td>
						 <td>教师名称</td>
						 <td>教师性别</td>
						 <td>身份证号</td>
						 <td>所属院系</td>
					</tr>
					<%
					 Teacher teachers = new Teacher();
					 Set<Teacher> list = (Set<Teacher>)session.getAttribute("teachers");
					 Iterator<Teacher> iterator = list.iterator();
					 while(iterator.hasNext()) {
					 	teachers = iterator.next();
					 %>
					 <tr>
					  	<td><%=teachers.getTeaid() %></td>
					  	<td><%=teachers.getTeaname() %></td>
					  	<td><%=teachers.getTeasex() %></td>
					  	<td><%=teachers.getTeaidentify() %></td>
					  	<td><%=teachers.getDept().getDeptname() %></td>
					 </tr>
					<%}}else if(str.equals("teacourses")){
					%>
					<tr>
						 <td>教师编号</td>
						 <td>教师名称</td>
						 <td>课程编号</td>
						 <td>课程名称</td>
					</tr>
					<%
					 TeaCourse teachercourses = new TeaCourse();
					 List<TeaCourse> list = (List<TeaCourse>)session.getAttribute("teacourses");
					 Iterator<TeaCourse> iterator = list.iterator();
					 while(iterator.hasNext()) {
					 	teachercourses = iterator.next();
					 %>
					 <tr>
					  	<td><%=teachercourses.getId().getTeaid() %></td>
					  	<td><%=teachercourses.getTeaname() %></td>
					  	<td><%=teachercourses.getId().getCourseid() %></td>
					  	<td><%=teachercourses.getCourse().getCoursename() %></td>
					 </tr>
					 <%}} %>
				</table>
				
			</div>
		</div>

		<script type="text/javascript">
			(function($) {
				$.expr[":"].Contains = function(a, i, m) {
					return(a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
				};

				function filterList(header, list) {
					//@header 头部元素
					//@list 无需列表
					//创建一个搜素表单
					var form = $("<form>").attr({
							"class": "filterform",
							action: "#"
						}),
						input = $("<input>").attr({
							"class": "filterinput",
							type: "text"
						});
					$(form).append(input).appendTo(header);
					$(input).change(function() {
						var filter = $(this).val();
						if(filter) {
							$matches = $(list).find("a:Contains(" + filter + ")").parent();
							$("li", list).not($matches).slideUp();
							$matches.slideDown();
						} else {
							$(list).find("li").slideDown();
						}
						return false;
					}).keyup(function() {
						$(this).change();
					});
				}
				$(function() {
					filterList($("#form"), $("#demo-list"));
				});
			})(jQuery);
		</script>
		<script type="text/javascript">
			jQuery("#jquery-accordion-menu").jqueryAccordionMenu();
		</script>
	</body>

</html>